package code.rocky.chapter01;

import java.text.NumberFormat;

public class Suggest4 {

    // 简单折扣计算
    public void calPrice(int price, int discount) {
        float knockdownPrice = price * discount / 100.0F;
        System.out.println("简单折扣后的价格是: " + formatCurrency(knockdownPrice));
    }
    // 复杂多折扣计算
    public void calPrice(int price, int... discounts) {
        float knockdownPrice = price;
        for (int discount : discounts) {
            knockdownPrice = price * discount / 100;
        }
        System.out.println("复杂折扣后的价格是: " + formatCurrency(knockdownPrice));
    }

    private String formatCurrency(float price) {
        return NumberFormat.getCurrencyInstance().format(price / 100);
    }

    public static void main(String[] args) {
        Suggest4 suggest4 = new Suggest4();
        suggest4.calPrice(49900, 75);
    }
}
